package com.codelint.gt20post;

import com.codelint.gt20post.codec.GT20CodecFactory;
import com.codelint.gt20post.pojo.GTObject;
import org.apache.log4j.Logger;
import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.filter.logging.LoggingFilter;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.Charset;

/**
 * User: light
 * Date: 5/27/13
 * Time: 4:49 PM
 */
public class App {

    public static Logger logger = Logger.getLogger("gt20post");

    private static final int PORT = 8609;

    public static void main(String[] args) throws Exception {
        logger.info("Start gt20post app...");
        IoAcceptor acceptor = new NioSocketAcceptor();
        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
        acceptor.getFilterChain().addLast(
                "codec", new ProtocolCodecFilter(new GT20CodecFactory()));
        acceptor.setHandler(new GTHandler());
        acceptor.bind(new InetSocketAddress(PORT));
    }
}
